Return type | Name and parameters |
---|---|
boolean
|
asBoolean()
Coerces a double array to a boolean value. |
double
|
average()
Calculates the average of the doubles in the array. |
boolean
|
contains(Object value)
Checks whether the array contains the given value. |
Number
|
count(Object value)
Counts the number of occurrences of the given value inside this array. |
DoubleStream
|
doubleStream()
Returns a sequential DoubleStream with the specified array as its source. |
Collection
|
flatten()
Flatten an array. |
List
|
getAt(IntRange range)
Support the subscript operator with an IntRange for a double array |
List
|
getAt(ObjectRange range)
Support the subscript operator with an ObjectRange for a double array |
List
|
getAt(Range range)
Support the subscript operator with a range for a double array |
List
|
getAt(Collection indices)
Support the subscript operator with a collection for a double array |
IntRange
|
getIndices()
Returns indices of the double array. |
Map
|
indexed()
Zips a double[] with indices in (index, value) order starting from index 0. |
Map
|
indexed(int offset)
Zips a double[] with indices in (index, value) order. |
String
|
join(String separator)
Concatenates the string representation of each item in this array, with the given String as a separator between each item. |
double
|
max()
Adds max() method to double arrays. |
double
|
min()
Adds min() method to double arrays. |
int
|
size()
Allows arrays to behave similar to collections. |
Stream
|
stream()
Returns a sequential Stream with the specified array as its source. |
double
|
sum()
Sums the items in an array. |
double
|
sum(double initialValue)
Sums the items in an array, adding the result to some initial value. |
double[]
|
swap(int i, int j)
Swaps two elements at the specified positions. |
List
|
toList()
Converts this array to a List of the same size, with each element added to the list. |
Set
|
toSet()
Converts this array to a Set, with each unique element added to the set. |
String
|
toString()
Returns the string representation of the given array. |
Coerces a double array to a boolean value. A double array is false if the array is of length 0, and true otherwise.
Calculates the average of the doubles in the array.
assert 5.0d == ([2,4,6,8] as double[]).average()
Checks whether the array contains the given value.
value
- the value being searched forCounts the number of occurrences of the given value inside this array.
Comparison is done using Groovy's == operator (using
compareTo(value) == 0
or equals(value)
).
value
- the value being searched forReturns a sequential DoubleStream with the specified array as its source.
Stream
for the arrayFlatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Support the subscript operator with an IntRange for a double array
range
- an IntRange indicating the indices for the items to retrieveSupport the subscript operator with an ObjectRange for a double array
range
- an ObjectRange indicating the indices for the items to retrieveSupport the subscript operator with a range for a double array
range
- a range indicating the indices for the items to retrieveSupport the subscript operator with a collection for a double array
indices
- a collection of indices for the items to retrieveReturns indices of the double array.
Zips a double[] with indices in (index, value) order starting from index 0.
Zips a double[] with indices in (index, value) order.
offset
- an index to start fromConcatenates the string representation of each item in this array, with the given String as a separator between each item.
separator
- a String separatorAdds max() method to double arrays.
Example usage:double[] nums = [1.1d, 2.2d, 3.3d] assert 3.3d == nums.max()
Adds min() method to double arrays.
Allows arrays to behave similar to collections.
Returns a sequential Stream with the specified array as its source.
Stream
for the arraySums the items in an array.
assert (1+2+3+4 as double) == ([1,2,3,4] as double[]).sum()
Sums the items in an array, adding the result to some initial value.
assert (5+1+2+3+4 as double) == ([1,2,3,4] as double[]).sum(5)
initialValue
- the items in the array will be summed to this initial valueSwaps two elements at the specified positions.
Example:
assert ([1, 3, 2, 4] as double[]) == ([1, 2, 3, 4] as double[]).swap(1, 2)
i
- a positionj
- a positionConverts this array to a List of the same size, with each element added to the list.
Converts this array to a Set, with each unique element added to the set.
Returns the string representation of the given array.